Skip to content

fix(dispatch): validate opencode auth-file and response JSON at the boundary (#7085) - #7088

Merged
dezren39 merged 1 commit into
mainfrom
creator-b/7085-opencode-parse
Nov 8, 2026
Merged

dezren39 merged 1 commit into
mainfrom
creator-b/7085-opencode-parse

Conversation

@dezren39

@dezren39 dezren39 commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Fixes #7085.

What

pm-stack/dispatch/src/opencode.ts: both JSON parses in the OpenCode client are now boundary validations in the module's own vocabulary.

  • authHeader(): malformed JSON -> OpenCodeError ("not valid JSON" + the file path); a non-object document (null/array/scalar) -> OpenCodeError ("does not hold a JSON object"); the password must be a non-empty string — a numeric or object password is rejected instead of being string-coerced into the live Authorization: Basic credential.
  • api(): a 2xx response with a non-JSON body -> OpenCodeError naming method/path/status instead of a raw SyntaxError.

Verification (laptop, this run)

  • Probe before the fix (real module verbatim, stub server): null auth file -> raw TypeError; {not json -> raw SyntaxError; {"password":12345} and {"password":{"x":1}} -> requests succeeded with coerced credentials; non-JSON 200 -> raw SyntaxError. Controls ({"password":…}, {}) behaved correctly.
  • New pm-stack/dispatch/test/opencode.test.ts: 8/8 pass on this branch; 5 fail on pre-fix code (the 3 controls pass both ways).
  • Full dispatch suite on the branch: 139/139 pass (bun test, 11 files).
  • bunx tsc --noEmit in the fresh worktree stops on a pre-existing missing @types/bun install (no node_modules in the worktree); unrelated to this diff.

Filed and self-solved by new-issue-creator-code-b under the guarded self-solve protocol (lifecycle §4).


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…oundary (#7085)

authHeader() parsed the OpenCode server state file with a bare JSON.parse + cast outside its readFile guard: a null document threw a raw TypeError, malformed JSON a raw SyntaxError, and a non-string password was silently coerced into the Basic credential (a numeric password was sent verbatim; an object became [object Object]). api() likewise let a non-JSON 200 escape as a raw SyntaxError. Both now throw OpenCodeError naming the problem, the password must be a non-empty string, and a new test/opencode.test.ts pins all probe cases (8 tests; 5 fail pre-fix). Full dispatch suite: 139/139 on the laptop.
@dezren39
dezren39 requested a review from a team as a code owner November 8, 2026 03:22
@dezren39 dezren39 added kind/bug Something isn't working (prefixed form of the classic bug label) source/creator Filed by the new-issue-creator job app/pm-stack pm-stack (Pad/Grist) in developing-today/code labels Nov 8, 2026
@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9f3f5520-66df-4f7c-8e1b-978ef6fe99a7
Commits

Reviewing files that changed from the base of the PR and between b9798fa and 97acc47.

Files selected for processing: 2

  • pm-stack/dispatch/src/opencode.ts
  • pm-stack/dispatch/test/opencode.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T03:23:20.868161Z 97acc47 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app/pm-stack pm-stack (Pad/Grist) in developing-today/code kind/bug Something isn't working (prefixed form of the classic bug label) source/creator Filed by the new-issue-creator job

Projects

None yet

1 participant